1. Field of the Invention
The present invention relates to a database management system for exclusive control to secure a lock on transactions and for securing execution rights for threads for a resource in a multi-thread environment.
2. Description of Related Art
A functionality referred to as the multi-thread is recently being widely used in operating systems. In this multi-thread environment, the virtual memory space of a plurality of multi-threads are used in common and the multi-threads are capable of parallel operation. Utilizing this kind of multi-threads typically provides the following listed effects so that multi-thread functions are effectively employed in database management systems requiring a plurality of simultaneous transactions.
One effect is improved throughput, in which thread processing provides improved throughput in response to numerous asynchronous requests occurring such as to file servers.
A second effect is improved response, in which requests from users are allocated to threads for improved response so that applications such as utilizing GUI (graphical user interfaces) do not have to be stopped.
A third effect is utilization of the multiprocessor, in which, in SMP systems having a plurality of processors, thread processing is allocated to each processor to make high speed calculation possible.
A fourth effect is conservation of memory resources, in which the threads commonly share the text zones, data zones, and heap zones inside an identical process area so that the necessary memory resources are available for running a plurality of tasks.
However, because each thread makes common use of the virtual memory space, synchronizing is needed to allow operation only of threads having execution rights from a synchronization processor in order that synchronization between threads is realized.
FIG. 13 shows update processing performed by threads 1, 2, and 3 of an application program 3 on identical data 5 (hereafter called the resource in the virtual memory space) of a virtual memory space 4. Access from each thread 1 through 3, to the resource 5 is performed by way of the synchronization processor 6. This synchronization processor 6 assigns execution rights in sequence so that the threads will operate to perform simultaneous update processing without conflicting with other threads.
Database management systems on the other hand are conventionally provided with an exclusive type control arrangement called a transaction. Accordingly, in order to configure a database management system of multithreads, the synchronizing of these threads and the exclusive control of transactions must be made to work in cooperation with each other.
FIG. 14 shows processing for differing transactions for each of threads 1, 2 and 3 of the application program 3 on the identical data 8 (hereafter called the database resource) of the database 7. An exclusive controller 9 obtains access to the database resource 8 by means of each transaction, and data is updated without conflicts among the threads, by the exclusive controller 9 assigning read and write rights to operate transactions in sequence.
Here, the database resource is loaded into the virtual memory space (cached) and operated as a resource in the virtual memory space (in other words a cache resource). Permission must be granted by both the synchronization processor and the exclusive controller in order to operate this cache by executing a transaction with a thread.
A method is known in the conventional art for cooperative operation of the transaction and the thread in the "ObjectStore C++API User Guide, Release 4, pp14-pp117." This document lists a method for cooperatively operating a transaction and a thread without permitting other thread transactions during the transaction process and also lists an operating method for processing all threads within the same transaction.
However, the former of these methods has the drawback that until a transaction is complete, a separate transaction can in no way be executed even if the transaction process has commenced, which in turn reduces thread ability to operate in parallel. Further, in the latter of the above two methods, one transaction can operate a plurality of threads, however the threads cannot commence a new transaction while the current transaction is in progress so that the ability of transactions to operate in parallel also decreased.
Further, Japanese Published Unexamined Patent Application No. Hei 7-84851 describes a control method for handling common data, using an object oriented database management system for common use of a plurality of threads of a database resource. In this method, the common data is assigned to threads having different virtual storage regions (pages in the embodiment) so that thread synchronization was unnecessary.
However, when a plurality of threads are operated in this method, the securing of numerous virtual memory storage zones is required and the actual memory space becomes compressed during simultaneous execution. Moreover, when a plurality of data is operated by a plurality of threads, the same data must be loaded into the virtual memory storage zones of each thread presenting the problem that the same data cannot be used efficiently in common by a plurality of threads.
These proposed methods therefore all had the drawbacks of not being able to operate threads efficiently or in parallel, in a database resource used as a cache resource in virtual memory space, when a plurality of threads were utilized for processing different transactions.
This drawback is the cause of the deadlock problem occurring between the synchronization processor for the threads and the transaction by the exclusive controller. When the database resource is loaded into the cache resource of the virtual memory space, the cache resource is then shared among the threads. A thread obtains execution rights from the synchronization processor when it is operating a cache resource. Also, when the securing of a lock on a database resource corresponding to a cache resource from the exclusive controller in needed, a deadlock occurs when securing of execution rights and securing of a lock cannot be smoothly and efficiently controlled.
The conditions causing a deadlock to occur are described in FIG. 15.
At time T1, a thread 1 receives execution rights from the synchronization processor for the cache resource. At time T2, a transaction A for thread 1 obtains an exclusive lock on the cache resource (page X). Then, at time T3, the thread 1 discards the execution rights and at this point the thread T2 which had been in standby to receive execution rights, now receives the execution rights.
Then at time T4, when a transaction B of the thread 2 requests an exclusive lock to page X, the exclusive controller sets the thread 2 to lock standby on account of the continued lock by transaction A. At time T5 when thread 1 again operates to request that execution rights be secured, the execution rights are still secured by the thread 2 so that the synchronization processor sets thread 1 to standby for execution rights. Therefore, at time T5, with the thread 1 in standby for execution rights, the thread 2 sets to standby for lock so that a deadlock has now occurred.